from scapy.all import Ether, ARP
from .sr import sendf

#############
#scan packet#
#############

class ArpScanPacket:
    def __init__(self, pdst):
        self.__packet__ = Ether() / ARP(pdst=pdst, op=1)
        self.send_type = 'sendp'
    
    @property
    def packet(self):
        return self.__packet__['Ether'] / self.__packet__['ARP']
    
    def remake(self):
        return self.packet

#########
#scanner#
#########

class EthernetScanner:
    def __init__(self):
        '''
        This is a scanner ues in ethernet.
        '''
        pass
    
    def scan(self, prefix):
        '''
        def _fill(string):
            unit = string.split('.')
            if len(unit)<4:
                output = ('.'.join(unit)+'.'+str(i) for i in range(0, 226))
            else:
                output = False
            return output
        res = _fill(prefix)
        if res:
            for i in range(3):
                if'''
        packets = ArpScanPacket()
        sendf(packets, show=True)
